﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class JobIntentionDao:IJobIntentionDao
    {
        private EFCoreDbContext _context;

        public JobIntentionDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddJobIntention(JobIntention jobIntention)
        {
            _context.JobIntentions.Add(jobIntention);
            _context.SaveChanges();
        }

        public void DeleteJobIntention(int id)
        {
            var jobIntention = _context.JobIntentions.FirstOrDefault(e => e.Id == id);
            _context.JobIntentions.Remove(jobIntention);
            _context.SaveChanges();
        }

        public JobIntention GetJobIntention(int applicantId)
        {
            return _context.JobIntentions.FirstOrDefault(e => e.ApplicantId == applicantId);
        }

        public void UpdataJobIntention(JobIntention jobIntention)
        {
            _context.JobIntentions.Update(jobIntention);
            _context.SaveChanges();
        }
    }
}
